<?php

namespace App\Http\Controllers\Admin\Assistant;

use App\Http\Controllers\Admin\BaseController;
use App\Repositories\UserRepositoryEloquent;

use App\User;
use App\Models\Commission;
use Breadcrumbs, Toastr,Config,Validator,DB;
use Illuminate\Http\Request;
use App\Models\FinancialDetails;

class SmsController extends BaseController{

    public function __construct()
    {
       
    }

    public function index(Request $request){
        $data=['type'=>-1,'name'=>'','mobile'=>'','from'=>'','to'=>''];
        $where=[];
        if(!empty($request->all())){
            //if($request->name){
            //dd($request->all());
            $datas = $request->all();
            foreach($datas as $k=>$v){
                if(($k=='mobile') && $v!=''){
                    $where[] = ["to",'like','%'.$v.'%'];
                }
                if($k=='from' && $v!=''){
                    //$where[] = ['created_at','>',strtotime($v)];
                    $where[] = ['created_at','>',$v];
                }
                if($k=='to' && $v!=''){
                    //$where[] = ["created_at",'<',strtotime($v)];
                    $where[] = ["created_at",'<',$v];
                }
                
                $data[$k] =$v;
                
            }
            //dd($where);
            //$users = User::where($where)->paginate(20);
        }


        $smses = DB::table('laravel_sms')->where($where)->orderBy('id','desc')->paginate(20);
        //dd($smses);
        return view('admin.assistant.sms',compact('smses','data'));
    }

    

}